//
//  WelcomeViewController.swift
//  CJPWB
//
//  Created by 陈锦彭 on 16/3/16.
//  Copyright © 2016年 chenjinpeng. All rights reserved.
//

import UIKit
import SDWebImage
class WelcomeViewController: UIViewController {

    ///头像
    @IBOutlet weak var iconView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var iconTopConstrain: NSLayoutConstraint!
    // MARK: - 系统回调函数
    override func viewDidLoad() {
        super.viewDidLoad()
//        //头像的下载
//        let urlStr = UserAccountViewModel.shareInstance.account?.avatar_large
//        guard let url = NSURL(string: urlStr!) else {return}
        iconView.sd_setImageWithURL(NSURL(string: UserAccountViewModel.shareInstance.account?.avatar_large ?? ""))
        //用户名
        nameLabel.text = UserAccountViewModel.shareInstance.account?.screen_name ?? "欢迎回来"
        
        //动画的实现
        self.iconTopConstrain.constant = 100
      UIView.animateWithDuration(2.0 , delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.1, options: [], animations: { () -> Void in
        self.view.layoutIfNeeded()
        }) { (_) -> Void in
            
                UIApplication.sharedApplication().keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
            
        }
       
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
